<template>
<div id="table1">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="代表处">
        <el-input v-model="formInline.user" placeholder="智能测试处"></el-input>
    </el-form-item>
    <el-form-item label="部门">
        <el-select v-model="formInline.region" placeholder="部门">
        <el-option label="测试部" value="ceshi"></el-option>
        <el-option label="销售部" value="xiaoshou"></el-option>
        </el-select>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
    </el-form>
    <!--表格-->
    <el-table
      ref="multipleTable"
      :data="tableData3"
      tooltip-effect="dark"
      style="width: 100%"
      border
      @selection-change="handleSelectionChange"
      >
      <el-table-column type="index" width="20"></el-table-column>
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column
        label="日期"
        width="120">
        <template slot-scope="scope">{{ scope.row.date }}</template>
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址"
        show-overflow-tooltip>
      </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
      <el-button @click="toggleSelection([tableData3[1], tableData3[2]])">切换第二、第三行的选中状态</el-button>
      <el-button @click="toggleSelection()">取消选择</el-button>
    </div>

</div>
</template>
<script>
  export default {
    data() {
      return {
        formInline: {
          user: '',
          region: ''
        },
        tableData3: [{
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-08',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-06',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-07',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }],
      }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      // cellClassNanmeHandle({columnIndex}){
      //   if (1 == columnIndex || columnIndex == 0) {
      //     // console.log(columnIndex)
      //     return 'cell-index'
      //   }
      // },
      // headerRowClassNanmeHandle({rowIndex}){
      //   // console.log(rowIndex)
      //   return 'cell-head'
      // }
    }
  }
</script>

<style scoped lang="scss">
  #table1{
    background-color: bisque;
    button{
      background-color: bisque;
    }
    .el-table__row{
      background-color: bisque;
    }
  }
  

</style>